// 导入了省市区的数据
import cityData from '@/assets/city_data2017_element.js'

export default {
  data() {
    return {
      queryinfo: {
        queryId: "",
        queryString: '',
        password: '',
        pageNo: 1,
        pageSize: 10
      },
      // certificate:['https://tgp125.cn/Fk1kdJW0YUg3UhONbnUIVaF69p0f','https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'],
      // 总记录条数
      total: 0,
      // 订单列表
      orderlist: [],
      // 控制 修改地址 对话框的显示与隐藏
      addressDialogVisible: false,
      addressForm: {
        // 省市区的数据
        address1: '',
        address2: ''
      },
      isAgainOrder: [{
          name: '请选择',
          status: 0
        },
        {
          name: '进行中',
          status: 1
        },
        {
          name: '待确认',
          status: 2
        },
        {
          name: '已完成',
          status: 3
        },
        {
          name: '已取消',
          status: 4
        },
        {
          name: '已失效',
          status: 5
        },
        {
          name: '申诉中',
          status: 6
        },
        {
          name: '申诉成功',
          status: 7
        },
        {
          name: '申诉失败',
          status: 8
        },
      ],
      addressFormRules: {
        address1: [{
          required: true,
          message: '请填写省市区',
          trigger: 'blur'
        }],
        address2: [{
          required: true,
          message: '请填写详细地址',
          trigger: 'blur'
        }]
      },
      // 省市区的数据
      cityData: cityData,
      // 控制 物流对话框的显示与隐藏
      wuliuDialogVisible: false,
      dialogTableVisible1: false,
      // 物流信息对象
      wuliuInfo: [],
      activeNames: ["1"],
      uuid: "",
      id: "",
      detileslist: [],
      url:
        "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
      srcList: [
        "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
        "https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg"
      ]
    }
  },
  created() {
    this.getOrderList()

  },
  methods: {
    getorderCynum(row) {
      if(row) {
        return row.feeMoney + row.numbers
      }
    },
    getordermoney(row){
      if(row) {
        return row.price*row.numbers
      }
    },
    handleChange(val) {
      console.log(val);
    },
    trundown() {
      this.$confirm("请仔细确认是否拒绝该申诉, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$http
            .post("/manage/otcOrder/changeReportFailure", {
              queryId: this.id
            })
            .then(res => {
                 if (res.data.status == 1) {

                  this.dialogTableVisible1 = false
                  this.getOrderList()
                    this.$message({
                    type: "success",
                    message: "申诉已拒绝"
                    });
                }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    consent() {
      this.$confirm("请仔细确认是否通过该申诉, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$http
            .post("/manage/otcOrder/changeReportSuccess", {
              queryId: this.id
            })
            .then(res => {
              if (res.data.status == 1) {
                this.dialogTableVisible1 = false
                this.getOrderList()
                this.$message({
                  type: "success",
                  message: "申诉已成功"
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    orderDataDetail(row) {
      //   console.log(this.uuid)
      this.$http
        .post("/manage/otcOrder/getReportOtcOrderInfoByOrderNo", {
          queryString: row.uuid
        })
        .then(res => {
          this.detileslist = res.data.data.list;
          console.log(this.detileslist);
          this.srcList = this.detileslist.reportPhotoList;
        });
    },
    chacke(row) {
      // console.log(row)
      // POST 
      this.dialogTableVisible1 = true
      // window.open('#/applyDetlie?seen=true&uuid='+row.uuid+
      // '&id='+row.id);
      this.id = row.id
      this.orderDataDetail(row);

    },
    getorderStatus(row) {
      // 6申诉中7申诉成功8申诉失败
      if (row.status == 1) {
        return '进行中'
      } else if (row.status == 2) {
        return '待确认'
      } else if (row.status == 3) {
        return '已完成'
      } else if (row.status == 4) {
        return '已取消'
      } else if (row.status == 5) {
        return '已失效'
      } else if (row.status == 6) {
        return '申诉中'
      } else if (row.status == 7) {
        return '申诉成功'
      } else if (row.status == 7) {
        return '申诉失败'
      }
    },
    // 获取订单列表
    // async getOrderList() {
    //   const { data: res } = await this.$http.post('/manage/otcOrder/list', this.queryinfo )

    //   if (res.meta.status !== 200) return this.$message.error('获取订单列表失败！')
    //   // console.log(res)
    //   this.orderlist = res.data.goods
    //   this.total = res.data.total
    // },
    getOrderList() {
      if (this.queryinfo.queryId == "") {
        this.queryinfo.queryId = 0
      }
      this.$http.post('/manage/otcOrder/list', this.queryinfo).then(res => {
        this.orderlist = res.data.data.list
        this.total = res.data.data.total
      })
    },
    handleSizeChange(newSize) {
      this.queryinfo.pageSize = newSize
      this.getOrderList()
    },
    handleCurrentChange(newPage) {
      this.queryinfo.pageNo = newPage
      this.getOrderList()
    },
    addressDialogClosed() {
      this.$refs.addressFormRef.resetFields()
    },
    // 点击按钮，显示 物流对话框
    async showWuliuDialog() {
      // 根据 物流运单号，获取到 物流信息
      const {
        data: res
      } = await this.$http.get('/kuaidi/619915933338')
      if (res.meta.status !== 200) return this.$message.error('获取物流信息失败！')
      this.wuliuInfo = res.data

      this.wuliuDialogVisible = true
    }
  }
}
